import i18n from '../../locales'
import type { LanguageCode, LanguageOption, LanguageState } from '@/types/pinia'

export const useLanguageStore = defineStore('language', {
	state: (): LanguageState => ({
		currentLanguage: 'zh-CN'
	}),
	getters: {
		getCurrentLanguage: state => state.currentLanguage,
		getLanguages: (): LanguageOption[] => [
			{
				label: '中文',
				value: 'zh-CN'
			},
			{
				label: 'English',
				value: 'en-US'
			},
			{
				label: 'Русский',
				value: 'ru-RU'
			}
		]
	},
	actions: {
		setLanguage(lang: LanguageCode) {
			this.currentLanguage = lang
			i18n.global.locale.value = lang
		}
	}
})
